package com.lcl.jarvis.admin.modules.person.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import com.lcl.jarvis.admin.modules.person.dto.request.TbEpidemiologicalInfoPageReqDTO;
import com.lcl.jarvis.admin.modules.person.dto.request.TbEpidemiologicalInfoReqDTO;
import com.lcl.jarvis.admin.modules.person.dto.response.TbEpidemiologicalInfoRespDTO;
import com.lcl.jarvis.admin.modules.person.service.ITbEpidemiologicalInfoService;
import lombok.RequiredArgsConstructor;
import com.lcl.jarvis.common.model.R;
import com.lcl.jarvis.common.model.PageResult;

/**
 * 数据筛查管理Controller
 *
 * @author licl
 * @date 2024-06-21 16:32:16
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/person/EpidemiologicalInfo")
public class TbEpidemiologicalInfoController {

    private final ITbEpidemiologicalInfoService tbEpidemiologicalInfoService;

    /**
     * 新增数据筛查管理
     *
     * @param body
     * @return
     */
    @PreAuthorize("hasAuthority('person:EpidemiologicalInfo:add')")
    @PostMapping
    public R<Integer> add(@RequestBody TbEpidemiologicalInfoReqDTO body) {
        return R.succeed(tbEpidemiologicalInfoService.add(body));
    }

    /**
     * 删除数据筛查管理
     *
     * @param ids
     * @return
     */
    @PreAuthorize("hasAuthority('person:EpidemiologicalInfo:remove')")
    @DeleteMapping("/{ids}")
    public R<Integer> remove(@PathVariable List<String> ids) {
        return R.succeed(tbEpidemiologicalInfoService.remove(ids));
    }

    /**
     * 修改数据筛查管理
     *
     * @param body
     * @return
     */
    @PreAuthorize("hasAuthority('person:EpidemiologicalInfo:edit')")
    @PutMapping
    public R<Integer> update(@RequestBody TbEpidemiologicalInfoReqDTO body) {
        return R.succeed(tbEpidemiologicalInfoService.update(body));
    }

    /**
     * 获取数据筛查管理详细信息
     *
     * @param id
     * @return
     */
    @PreAuthorize("hasAuthority('person:EpidemiologicalInfo:query')")
    @GetMapping(value = "/{id}")
    public R<TbEpidemiologicalInfoRespDTO> detail(@PathVariable("id") String id) {
        return R.succeed(tbEpidemiologicalInfoService.detail(id));
    }

    /**
     * 查询数据筛查管理列表
     *
     * @param req
     * @return
     */
    @PreAuthorize("hasAuthority('person:EpidemiologicalInfo:list')")
    @GetMapping("/list")
    public R<PageResult<TbEpidemiologicalInfoRespDTO>> page(TbEpidemiologicalInfoPageReqDTO req) {
        return R.succeed(tbEpidemiologicalInfoService.page(req));
    }

}
